package com.njlime.core.helper.dic;


import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * Created by Dean on 2017-9-7.
 */
@Component
public class DictionaryListener implements ServletContextListener {
    private static WatchFilePathTask r = new WatchFilePathTask();

    private Logger log = Logger.getLogger(DictionaryListener.class);

    @Override
    public void contextDestroyed(ServletContextEvent paramServletContextEvent) {
        //r.interrupt();
    }

    @Override
    public void contextInitialized(ServletContextEvent paramServletContextEvent) {
        ObserverListener listen = new ObserverListener();
        //给监控指定目录下的线程”(被观察者)，添加一个观察者
        r.addObserver(listen);
        new Thread(r).start();
        log.info("ImportUserFromFileTask is started!");
    }

}
